package com.sg.service.biz.app.nb;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.dto.biz.app.common.SeparateKeyClassPropertyCodeDto;
import com.sg.dto.biz.app.req.*;
import com.sg.dto.biz.app.res.*;
import com.sg.dto.integration.component.QuerySemanticEngineDetailReqDto;
import com.sg.dto.integration.component.QuerySemanticEngineDetailRespDto;
import com.wicket.okrcomponent.integration.TemplateEngineService;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author ： 手工接入方法
 * @version 1.0
 * @since 2022/5/28 15:32
 */
@Service
public class NbChangeColumn {

    @Resource
    private TemplateEngineService fwCompTemplateEngineClient;

    /**
     * code:receptionService
     * name:M3-获取接收批次现状字段
     * desc:undefined
     * gen by moon at 8/29/2022, 12:45:16 PM
     **/
    @Trace(operationName = "M3-获取接收批次现状字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainReceiveFieldRespDto obtainReceiveField(ObtainReceiveFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ObtainReceiveFieldRespDto.class);
    }

    /**
     * code:filterUpdateFieldPrimaryKey
     * name:M3-13-02执行业务应用筛选更新字段主键（特殊方法）
     * desc:undefined
     * gen by moon at 9/13/2022, 12:35:56 AM
     **/
    @Trace(operationName = "M3-13-02执行业务应用筛选更新字段主键（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizScreenUpdateFieldFkRespDto implementBizScreenUpdateFieldFk(ImplementBizScreenUpdateFieldFkReqDto reqDto) {

        ImplementBizScreenUpdateFieldFkRespDto retData = new ImplementBizScreenUpdateFieldFkRespDto();
        if (reqDto == null || reqDto.getBizAppChangeColList() == null || reqDto.getBizAppChangeColList().size() == 0) {
            return retData;
        }
        BizAppChangeColDto oneElm = reqDto.getBizAppChangeColList().get(0);
        if (oneElm.getTableTypeCode() == null || oneElm.getTableTypeCode().isEmpty()) {
            return retData;
        } else if (oneElm.getTableTypeCode().equals("OMS_TARGET_OBJECTIVE")) {
            retData.setObjectiveId(oneElm.getEntityId());
        }
        return retData;
    }

    /**
     * code:concatenateMasterTableRevisionRecords
     * name:M3-13-02执行业务应用拼接主表修订记录（特殊方法）
     * desc:undefined
     * gen by moon at 9/13/2022, 12:35:57 AM
     **/
    @Trace(operationName = "M3-13-02执行业务应用拼接主表修订记录（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizSplicingMainTableRevisionRecordRespDto implementBizSplicingMainTableRevisionRecord(ImplementBizSplicingMainTableRevisionRecordReqDto reqDto) {
        ImplementBizSplicingMainTableRevisionRecordRespDto retData = new ImplementBizSplicingMainTableRevisionRecordRespDto();
        Map<String, BizAppChangeColDto> indexPool = new HashMap<>();
        for (BizAppChangeColDto oneColumn : reqDto.getBizAppChangeColList()) {
            if (oneColumn.getTableTypeCode().equals("OMS_TARGET_OBJECTIVE")) {
                //部门有多个字段，所以map中的key要按主键id+字段名称的方式来建立
                BizAppChangeColDto exisitElm = indexPool.get(oneColumn.getEntityId() + oneColumn.getObjectPropertyCode());
                if (exisitElm == null) {
                    indexPool.put(oneColumn.getEntityId() + oneColumn.getObjectPropertyCode(), BeanUtil.toBean(oneColumn, BizAppChangeColDto.class));
                } else if (exisitElm.getOperateTime().compareTo(oneColumn.getOperateTime()) <= 0) {
                    indexPool.put(oneColumn.getEntityId() + oneColumn.getObjectPropertyCode(), BeanUtil.toBean(oneColumn, BizAppChangeColDto.class));
                }
            }
        }

        Map<String, TargetObjDto> targetObjInfo = new HashMap<>();
        for (BizAppChangeColDto oneElm : indexPool.values()) {
            TargetObjDto exisitElm = targetObjInfo.get(oneElm.getEntityId());
            if (exisitElm == null) {
                TargetObjDto oneDept = buildTarget(oneElm);
                targetObjInfo.put(oneElm.getEntityId(), oneDept);
            } else {
                updateTarget(exisitElm, oneElm);
            }
        }
        retData.setTargetObjList(targetObjInfo.values().stream().map(p -> BeanUtil.toBean(p, TargetObjDto.class)).collect(Collectors.toList()));
        return retData;
    }

    private TargetObjDto buildTarget(BizAppChangeColDto column) {
        TargetObjDto retData = new TargetObjDto();
        retData.setObjectiveId(column.getEntityId());
        if (column.getObjectPropertyCode() == null) {
            return retData;
        } else if (column.getObjectPropertyCode().equals("objectiveName")) {
            retData.setObjectiveName(column.getMetaDataColumnContent());
        } else if (column.getObjectPropertyCode().equals("objectiveShortName")) {
            retData.setObjectiveShortName(column.getMetaDataColumnContent());
        }
        return retData;
    }

    private void updateTarget(TargetObjDto target, BizAppChangeColDto column) {
        if (column.getObjectPropertyCode() == null) {
            return;
        } else if (column.getObjectPropertyCode().equals("objectiveName")) {
            target.setObjectiveName(column.getMetaDataColumnContent());
        } else if (column.getObjectPropertyCode().equals("objectiveShortName")) {
            target.setObjectiveShortName(column.getMetaDataColumnContent());
        }
        return;
    }

    /**
     * code:generateSemanticInstance
     * name:M3-生成变更字段语义故事内容
     * desc:undefined
     * gen by moon at 9/18/2022, 8:31:18 PM
     **/
    @Trace(operationName = "M3-生成变更字段语义故事内容")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public GenerateSemanticContentRespDto generateSemanticContent(GenerateSemanticContentReqDto reqDto) {
        //ADD_SUBJECT_CONT
        //ARCHIVE_SUBJECT_CONT
        //SUBJECT_CHANGE_CONT
        boolean bRetFlag = false;
        GenerateSemanticContentRespDto retData = new GenerateSemanticContentRespDto();
        String retConent = "";
        QuerySemanticEngineDetailReqDto querySemanticEngineDetailReqDto = new QuerySemanticEngineDetailReqDto();
        querySemanticEngineDetailReqDto.setTemplateSemanticEngineCode("ADD_SUBJECT_CONT");
        QuerySemanticEngineDetailRespDto querySemanticEngineDetailRespDto = fwCompTemplateEngineClient.querySemanticEngineDetail(querySemanticEngineDetailReqDto).getData();
        if (querySemanticEngineDetailRespDto != null && querySemanticEngineDetailRespDto.getTemplateEngineTemplate() != null) {
            String addBehaviorNameTag = "\\{addBehaviorName}";
            String addSubjectContent = "\\{addSubjectContent}";
            String subjectContAffiliationParentCont = "\\{subjectContAffiliationParentCont}";
            if (reqDto.getAddBehaviorName() != null && !reqDto.getAddBehaviorName().isEmpty()) {
                bRetFlag = true;
                retConent = querySemanticEngineDetailRespDto.getTemplateEngineTemplate().replaceAll(addBehaviorNameTag, reqDto.getAddBehaviorName());
            } else {
                retConent = querySemanticEngineDetailRespDto.getTemplateEngineTemplate().replaceAll(addBehaviorNameTag, "---");
            }

            if (reqDto.getAddSubjectContent() != null && !reqDto.getAddSubjectContent().isEmpty()) {
                retConent = retConent.replaceAll(addSubjectContent, reqDto.getAddSubjectContent());
            } else {
                retConent = retConent.replaceAll(addSubjectContent, "---");
            }

            if (reqDto.getSubjectContAffiliationParentCont() != null && !reqDto.getSubjectContAffiliationParentCont().isEmpty()) {
                retConent = retConent.replaceAll(subjectContAffiliationParentCont, reqDto.getSubjectContAffiliationParentCont());
            } else {
                retConent = retConent.replaceAll(subjectContAffiliationParentCont, "---");
            }


            if (retConent != null && !retConent.isEmpty()) {
                retConent = retConent.replaceAll("---", "");
                retConent = retConent.replaceAll("（）", "");
                retData.setObjectName(retConent);
            }

            if (bRetFlag) {
                return retData;
            }

        }

        retConent = "";
        QuerySemanticEngineDetailReqDto querySemanticEngineDetailReqDto_2 = new QuerySemanticEngineDetailReqDto();
        querySemanticEngineDetailReqDto_2.setTemplateSemanticEngineCode("ARCHIVE_SUBJECT_CONT");
        QuerySemanticEngineDetailRespDto querySemanticEngineDetailRespDto_2 = fwCompTemplateEngineClient.querySemanticEngineDetail(querySemanticEngineDetailReqDto_2).getData();
        if (querySemanticEngineDetailRespDto_2 != null && querySemanticEngineDetailRespDto_2.getTemplateEngineTemplate() != null) {
            String archiveBehaviorName = "\\{archiveBehaviorName}";
            String archiveSubjectContent = "\\{archiveSubjectContent}";
            String subjectContAffiliationParentCont = "\\{subjectContAffiliationParentCont}";
            if (reqDto.getArchiveBehaviorName() != null && !reqDto.getArchiveBehaviorName().isEmpty()) {
                bRetFlag = true;
                retConent = querySemanticEngineDetailRespDto_2.getTemplateEngineTemplate().replaceAll(archiveBehaviorName, reqDto.getArchiveBehaviorName());
            } else {
                retConent = querySemanticEngineDetailRespDto_2.getTemplateEngineTemplate().replaceAll(archiveBehaviorName, "---");
            }

            if (reqDto.getArchiveSubjectContent() != null && !reqDto.getArchiveSubjectContent().isEmpty()) {
                retConent = retConent.replaceAll(archiveSubjectContent, reqDto.getArchiveSubjectContent());
            } else {
                retConent = retConent.replaceAll(archiveSubjectContent, "---");
            }

            if (reqDto.getSubjectContAffiliationParentCont() != null && !reqDto.getSubjectContAffiliationParentCont().isEmpty()) {
                retConent = retConent.replaceAll(subjectContAffiliationParentCont, reqDto.getSubjectContAffiliationParentCont());
            } else {
                retConent = retConent.replaceAll(subjectContAffiliationParentCont, "---");
            }

            if (retConent != null && !retConent.isEmpty()) {
                retConent = retConent.replaceAll("---", "");
                retConent = retConent.replaceAll("（）", "");
                retData.setObjectName(retConent);
            }

            if (bRetFlag) {
                return retData;
            }
        }

        retConent = "";
        QuerySemanticEngineDetailReqDto querySemanticEngineDetailReqDto_3 = new QuerySemanticEngineDetailReqDto();
        querySemanticEngineDetailReqDto_3.setTemplateSemanticEngineCode("SUBJECT_CHANGE_CONT");
        QuerySemanticEngineDetailRespDto querySemanticEngineDetailRespDto_3 = fwCompTemplateEngineClient.querySemanticEngineDetail(querySemanticEngineDetailReqDto_3).getData();
        if (querySemanticEngineDetailRespDto_3 != null && querySemanticEngineDetailRespDto_3.getTemplateEngineTemplate() != null) {
            String reviseSubjectContent = "\\{reviseSubjectContent}";
            String reviseBehaviorName = "\\{reviseBehaviorName}";
            String columnContent = "\\{columnContent}";
            if (reqDto.getReviseSubjectContent() != null && !reqDto.getReviseSubjectContent().isEmpty()) {
                bRetFlag = true;
                retConent = querySemanticEngineDetailRespDto_3.getTemplateEngineTemplate().replaceAll(reviseSubjectContent, reqDto.getReviseSubjectContent());
            } else {
                retConent = querySemanticEngineDetailRespDto_3.getTemplateEngineTemplate().replaceAll(reviseSubjectContent, "---");
            }

            if (reqDto.getReviseBehaviorName() != null && !reqDto.getReviseBehaviorName().isEmpty()) {
                retConent = retConent.replaceAll(reviseBehaviorName, reqDto.getReviseBehaviorName());
            } else {
                retConent = retConent.replaceAll(reviseBehaviorName, "---");
            }

            if (reqDto.getColumnContent() != null && !reqDto.getColumnContent().isEmpty()) {
                retConent = retConent.replaceAll(columnContent, reqDto.getColumnContent());
            } else {
                retConent = retConent.replaceAll(columnContent, "---");
            }

            if (retConent != null && !retConent.isEmpty()) {
                retConent = retConent.replaceAll("---", "");
                retConent = retConent.replaceAll("（）", "");
                retData.setObjectName(retConent);
            }

            if (bRetFlag) {
                return retData;
            }
        }

        return retData;
    }

    /**
     * code:dataAuClassification
     * name:M3-13-02更新字段中，过滤新增、修改字段（特殊方法）
     * desc:undefined
     * gen by moon at 9/18/2022, 8:31:34 PM
     **/
    @Trace(operationName = "M3-13-02更新字段中，过滤新增、修改字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public RefreshChangeColumnRespDto refreshChangeColumn(RefreshChangeColumnReqDto reqDto) {
        RefreshChangeColumnRespDto retData = new RefreshChangeColumnRespDto();
        List<NewColumnDto> addList = new ArrayList<>();
        List<ModifyColumnDto> changeList = new ArrayList<>();
        Map<String, BizAppChangeColDto> index = new HashMap<>();
        if (CollUtil.isEmpty(reqDto.getChangeColumnList())) {
            return retData;
        }
        if (CollUtil.isEmpty(reqDto.getBizAppChangeColList())) {
            for (ChangeColumnDto one : reqDto.getChangeColumnList()) {
                NewColumnDto base = new NewColumnDto();
                BeanUtil.copyProperties(one, base);
                addList.add(base);
            }
            retData.setNewColumnList(addList);
            return retData;
        }

        for (BizAppChangeColDto oneBase : reqDto.getBizAppChangeColList()) {
            index.put(oneBase.getObjectPropertyCode(), oneBase);
        }

        for (ChangeColumnDto oneChange : reqDto.getChangeColumnList()) {
            BizAppChangeColDto dbData = index.get(oneChange.getObjectPropertyCode());
            if (dbData == null) {
                NewColumnDto base = new NewColumnDto();
                BeanUtil.copyProperties(oneChange, base);
                addList.add(base);
            } else {
                ModifyColumnDto change = new ModifyColumnDto();
                BeanUtil.copyProperties(oneChange, change);
                change.setChangeColumnId(dbData.getChangeColumnId());
                changeList.add(change);
            }
        }
        retData.setNewColumnList(addList);
        retData.setModifyColumnList(changeList);
        return retData;
    }

    /**
     * code:receptionService
     * name:M3执行业务应用构造出入参字段（特殊方法）
     * desc:undefined
     * gen by moon at 11/17/2022, 7:20:25 AM
     **/
    @Trace(operationName = "M3执行业务应用构造出入参字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizConstructAccessParameterFieldRespDto implementBizConstructAccessParameterField(ImplementBizConstructAccessParameterFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementBizConstructAccessParameterFieldRespDto.class);
    }

    /**
     * code:dataFilterSpecRecBy
     * name:M3-13-02执行字段过滤相同变更记录列表（特殊方法）
     * desc:undefined
     * gen by moon at 11/17/2022, 7:20:32 AM
     **/
    @Trace(operationName = "M3-13-02执行字段过滤相同变更记录列表（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementFieldFilterIdenticalChangeColumnRespDto implementFieldFilterIdenticalChangeColumn(ImplementFieldFilterIdenticalChangeColumnReqDto reqDto) {
        ImplementFieldFilterIdenticalChangeColumnRespDto retData = new ImplementFieldFilterIdenticalChangeColumnRespDto();
        List<ChangeColumnDto> filtered = new ArrayList<>();
        for (ChangeColumnDto one : reqDto.getChangeColumnList()) {
            if (one.getEntityId().equals(reqDto.getEntityId())) {
                filtered.add(one);
            }
        }
        retData.setChangeColumnList(filtered);
        return retData;
    }

    /**
     * code:mergeChangeColumnDetail
     * name:M3执行业务应用内容详情合并字段（特殊方法）
     * desc:undefined
     * gen by moon at 11/17/2022, 8:30:20 PM
     **/
    @Trace(operationName = "M3执行业务应用内容详情合并字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementBizAppContentDetailsMergeFieldsRespDto implementBizAppContentDetailsMergeFields(ImplementBizAppContentDetailsMergeFieldsReqDto reqDto) {
        ImplementBizAppContentDetailsMergeFieldsRespDto retData = new ImplementBizAppContentDetailsMergeFieldsRespDto();
        BeanUtil.copyProperties(reqDto, retData);
        if (reqDto.getBizAppChangeColList() == null) {
            return retData;
        }

        Map<String, Field> fieldIndex = new HashMap<>();
        Field[] declaredFields = retData.getClass().getDeclaredFields();
        for (Field field : declaredFields) {
            fieldIndex.put(field.getName(), field);
        }

        for (BizAppChangeColDto baseChange : reqDto.getBizAppChangeColList()) {
            Field fileObj = fieldIndex.get(baseChange.getObjectPropertyCode());
            fileObj.setAccessible(true);
            try {
                fileObj.set(retData, baseChange.getMetaDataColumnContent());
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return retData;
    }

    /**
     * code:mergeChangeColumnList
     * name:M3执行分离同类主键变更字段（特殊方法）
     * desc:undefined
     * gen by moon at 11/17/2022, 8:30:55 PM
     **/
    @Trace(operationName = "M3执行分离同类主键变更字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementSeparateKeyClassPropertyCodeRespDto implementSeparateKeyClassPropertyCode(ImplementSeparateKeyClassPropertyCodeReqDto reqDto) {
        ImplementSeparateKeyClassPropertyCodeRespDto retData = new ImplementSeparateKeyClassPropertyCodeRespDto();
        //拆分成三个小数据集
        List<SeparateKeyClassPropertyCodeDto> evaObjTargetCycleIdList = new ArrayList<>();
        List<SeparateKeyClassPropertyCodeDto> objTargetCycleWeightSetIdList = new ArrayList<>();
        List<SeparateKeyClassPropertyCodeDto> evaObjOsetIdList = new ArrayList<>();

        Map<String, EvaObjTargetCycleOsetDto> evaObjTargetCycleOsetIndex = new HashMap<>();
        Map<String, EvaObjTargetCycleWeightDto> evaObjTargetCycleWeightIndex = new HashMap<>();
        Map<String, EvaObjTargetCycleDto> evaObjTargetCycleIndex = new HashMap<>();

        if (CollectionUtil.isNotEmpty(reqDto.getEvaObjTargetCycleOsetList())) {
            for (EvaObjTargetCycleOsetDto one : reqDto.getEvaObjTargetCycleOsetList()) {
                evaObjTargetCycleOsetIndex.put(one.getEvaObjOsetId(), one);
            }
            retData.setEvaObjTargetCycleOsetList(reqDto.getEvaObjTargetCycleOsetList());
        }

        if (CollectionUtil.isNotEmpty(reqDto.getEvaObjTargetCycleWeightList())) {
            for (EvaObjTargetCycleWeightDto one : reqDto.getEvaObjTargetCycleWeightList()) {
                evaObjTargetCycleWeightIndex.put(one.getObjTargetCycleWeightSetId(), one);
            }
            retData.setEvaObjTargetCycleWeightList(reqDto.getEvaObjTargetCycleWeightList());
        }

        if (CollectionUtil.isNotEmpty(reqDto.getEvaObjTargetCycleList())) {
            for (EvaObjTargetCycleDto one : reqDto.getEvaObjTargetCycleList()) {
                evaObjTargetCycleIndex.put(one.getEvaObjTargetCycleId(), one);
            }
            retData.setEvaObjTargetCycleList(reqDto.getEvaObjTargetCycleList());
        }

        for (SeparateKeyClassPropertyCodeDto one : reqDto.getSeparateKeyClassPropertyCodeList()) {
            if (one.getEntityName().equals("evaObjTargetCycleId")) {
                evaObjTargetCycleIdList.add(one);
            } else if (one.getEntityName().equals("objTargetCycleWeightSetId")) {
                objTargetCycleWeightSetIdList.add(one);
            } else if (one.getEntityName().equals("evaObjOsetId")) {
                evaObjOsetIdList.add(one);
            }
        }

        for (SeparateKeyClassPropertyCodeDto one : evaObjTargetCycleIdList) {
            EvaObjTargetCycleDto elm = evaObjTargetCycleIndex.get(one.getEntityId());
            if (one.getObjectPropertyCode().equals("targetCycleName")) {
                elm.setTargetCycleName(one.getMetaDataColumnContent());
            } else if (one.getObjectPropertyCode().equals("cyclelAlias")) {
                elm.setCyclelAlias(one.getMetaDataColumnContent());
            }
        }

        for (SeparateKeyClassPropertyCodeDto one : evaObjOsetIdList) {
            EvaObjTargetCycleOsetDto elm = evaObjTargetCycleOsetIndex.get(one.getEntityId());
            if (one.getObjectPropertyCode().equals("targetValue")) {
                elm.setTargetValue(Double.valueOf(one.getMetaDataColumnContent()));
            } else if (one.getObjectPropertyCode().equals("targetDiagnosticValue")) {
                elm.setTargetDiagnosticValue(Double.valueOf(one.getMetaDataColumnContent()));
            }
        }

        for (SeparateKeyClassPropertyCodeDto one : objTargetCycleWeightSetIdList) {
            EvaObjTargetCycleWeightDto elm = evaObjTargetCycleWeightIndex.get(one.getEntityId());
            if (one.getObjectPropertyCode().equals("weightValue")) {
                elm.setWeightValue(Double.valueOf(one.getMetaDataColumnContent()));
            } else if (one.getObjectPropertyCode().equals("weightScore")) {
                elm.setWeightScore(Double.valueOf(one.getMetaDataColumnContent()));
            }
        }


        return retData;
    }

    /**
     * code:mainTableAnalyseChangeColumn
     * name:M3执行主表记录转化变更字段（特殊方法）
     * desc:undefined
     * gen by moon at 12/13/2022, 3:32:25 AM
     **/
    @Trace(operationName = "M3执行主表记录转化变更字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementMainTableAnalyseChangeColumnRespDto implementMainTableAnalyseChangeColumn(ImplementMainTableAnalyseChangeColumnReqDto reqDto) {
        ImplementMainTableAnalyseChangeColumnRespDto retData = new ImplementMainTableAnalyseChangeColumnRespDto();
        for (EvaObjTargetCycleWeightDto one : reqDto.getEvaObjTargetCycleWeightList()) {
            ChangeColumnDto elm = new ChangeColumnDto();
            elm.setEntityId(one.getObjTargetCycleWeightSetId());
            if (one.getTargetCycleContentId() != null) {
                elm.setCustomField(one.getTargetCycleContentId());
            } else {
                elm.setCustomField(one.getEvaObjTargetCycleId());
            }

            elm.setObjectPropertyCode("weightScore");
            elm.setMetaDataColumnContent(String.valueOf(one.getWeightScore()));
            retData.getChangeColumnList().add(elm);

            ChangeColumnDto elm2 = new ChangeColumnDto();
            elm2.setEntityId(one.getObjTargetCycleWeightSetId());
            if (one.getTargetCycleContentId() != null) {
                elm.setCustomField(one.getTargetCycleContentId());
            } else {
                elm.setCustomField(one.getEvaObjTargetCycleId());
            }
            elm2.setObjectPropertyCode("weightValue");
            elm2.setMetaDataColumnContent(String.valueOf(one.getWeightValue()));
            retData.getChangeColumnList().add(elm2);
        }
        return retData;
    }

    /**
     * code:retainFrontCoverBackChangeColum
     * name:M3执行保留前覆盖后端变更字段（特殊方法）
     * desc:undefined
     * gen by moon at 12/13/2022, 3:32:33 AM
     **/
    @Trace(operationName = "M3执行保留前覆盖后端变更字段（特殊方法）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementRetainFrontCoverBackChangeColumnRespDto implementRetainFrontCoverBackChangeColumn(ImplementRetainFrontCoverBackChangeColumnReqDto reqDto) {
        ImplementRetainFrontCoverBackChangeColumnRespDto retData = new ImplementRetainFrontCoverBackChangeColumnRespDto();
        Map<String, BizAppChangeColDto> index = new HashMap<>();
        for (BizAppChangeColDto one : reqDto.getBizAppChangeColList()) {
            index.put(one.getEntityId() + one.getCustomField(), one);
        }

        for (ChangeColumnDto one : reqDto.getChangeColumnList()) {
            if (index.containsKey(one.getEntityId() + one.getCustomField())) {
                BizAppChangeColDto target = index.get(one.getEntityId() + one.getCustomField());
                ChangeColumnDto elm = new ChangeColumnDto();
                elm.setEntityId(target.getEntityId());
                elm.setCustomField(target.getCustomField());
                elm.setObjectPropertyName(one.getObjectPropertyName());
                elm.setColumnContent(one.getColumnContent());
                elm.setOriColumnContent(one.getOriColumnContent());
                elm.setObjectPropertyCode(target.getObjectPropertyCode());
                elm.setMetaDataColumnContent(target.getMetaDataColumnContent());
                retData.getChangeColumnList().add(elm);
            }
        }
        return retData;
    }
    //手工接入方法
}
